<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Count the number of entries in a search</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.ldap-control-paged-result.html">« ldap_control_paged_result</a></li>
      <li style="float: right;"><a href="function.ldap-count-references.html">ldap_count_references »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.ldap.html">LDAP 函数</a></li>
    <li>Count the number of entries in a search</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.ldap-count-entries" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ldap_count_entries</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ldap_count_entries</span> &mdash; <span class="dc-title">Count the number of entries in a search</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ldap-count-entries-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ldap_count_entries</strong></span>(<span class="methodparam"><span class="type"><a href="class.ldap-connection.html" class="type LDAP\Connection">LDAP\Connection</a></span> <code class="parameter">$ldap</code></span>, <span class="methodparam"><span class="type"><a href="class.ldap-result.html" class="type LDAP\Result">LDAP\Result</a></span> <code class="parameter">$result</code></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   Returns the number of entries stored in the result of previous search
   operations.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ldap-count-entries-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">ldap</code></dt>

     <dd>

      <p class="para">
       通过 <span class="function"><a href="function.ldap-connect.html" class="function">ldap_connect()</a></span> 返回的 <span class="classname"><a href="class.ldap-connection.html" class="classname">LDAP\Connection</a></span> 实例。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">result</code></dt>

     <dd>

      <p class="para">
       通过 <span class="function"><a href="function.ldap-list.html" class="function">ldap_list()</a></span> 或者 <span class="function"><a href="function.ldap-search.html" class="function">ldap_search()</a></span> 返回的 <span class="classname"><a href="class.ldap-result.html" class="classname">LDAP\Result</a></span> 实例。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ldap-count-entries-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns number of entries in the result, 或者在失败时返回 <strong><code>false</code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.ldap-count-entries-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">ldap</code> 参数接受 <span class="classname"><a href="class.ldap-connection.html" class="classname">LDAP\Connection</a></span>
  实例，之前接受 <a href="language.types.resource.html" class="link">资源(resource)</a>。
 </td>
</tr>

     <tr>
 <td>8.1.0</td>
 <td>
  The <code class="parameter">result</code> parameter expects an <span class="classname"><a href="class.ldap-result.html" class="classname">LDAP\Result</a></span>
  instance now; previously, a <a href="language.types.resource.html" class="link">资源(resource)</a> was expected.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.ldap-count-entries-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="ldap-count-entries.example.basic">
    <p><strong>示例 #1 <span class="function"><strong>ldap_count_entries()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     Retrieve number of entries in the result.
    </p></div>
    <div class="example-contents">
     <div class="phpcode"><code><span style="color: #000000">
//&nbsp;$ds&nbsp;is&nbsp;a&nbsp;valid&nbsp;LDAP\Connection&nbsp;instance&nbsp;for&nbsp;a&nbsp;directory&nbsp;server<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$dn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;'ou=example,dc=org';<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$filter&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;'(|(sn=Doe*)(givenname=John*))';<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$justthese&nbsp;=&nbsp;array('ou',&nbsp;'sn',&nbsp;'givenname',&nbsp;'mail');<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sr&nbsp;=&nbsp;ldap_search($ds,&nbsp;$dn,&nbsp;$filter,&nbsp;$justthese);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var_dump(ldap_count_entries($ds,&nbsp;$sr));</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
     <div class="cdata"><pre>
     int(1)
     </pre></div>
    </div>
   </div>
  </p>
 </div>

</div></div></div></body></html>